/*
 * @author: huangww
 * @Date: 2021-02-22 14:51:12
 * @LastEditTime: 2021-03-01 14:39:37
 * @FilePath: \fmgr\src\core\mgr\DataMgr.ts
 */
namespace core {
    /**
     * 消息中继，数据整理
     */
    export class DataMgr {
        private static instance: DataMgr;
        private _logic: DataLogic;
        static getInstance() {
            if (!this.instance) {
                this.instance = new DataMgr();
            }
            return this.instance;
        }

        constructor() {
            this._logic = new DataLogic();
        }

        setData(msg: Msg) {
            this._logic.setData(msg);
        }
        /**socket请求 */
        requestMsg(msg: Msg, waiting = false) {
            this._logic.check(msg, waiting = false);
        }

        request(mode: DATAMODULE, action: string, data = null, waiting = false) {
            let msg = new Msg(mode, action, data);
            this.requestMsg(msg, waiting);
        }

        //http请求
        post(url: string, params: Params, msg: Msg, waiting = false) {
            this._logic.post(url, params, msg, waiting = false);
        }

    }
}